home *** CD-ROM | disk | FTP | other *** search
/ Merciful 1 / Merciful - Disc 1.iso / software / f / friday_night_pool / fridaynightpool.dms / fridaynightpool.adf / source / load.c < prev    next >
C/C++ Source or Header  |  1978-02-25  |  16KB  |  583 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <graphics/view.h>
  4. #include <intuition/intuition.h>
  5. #include <graphics/gfxmacros.h>
  6. #include <proto/exec.h>
  7. #include <proto/graphics.h>
  8. #include <proto/intuition.h>
  9. #include <dos.h>
  10. #include <proto/dos.h>
  11. #include <devices/audio.h>
  12.  
  13. #define UP 1
  14. #define DOWN 2
  15. #define ON 1
  16. #define OFF 0
  17.  
  18. #define VERIFY    0
  19. #define VIEW    1
  20. #define NOREFRESH 2    /* Prevents calls to MakeScreen(s); RethinkDisplay(); */
  21.  
  22. #undef SINGLE
  23.  
  24. enum icons { PLYR1,PLYR2,PRACTICE,DEMO,PLAY,QUIT,_BAIZE,_BALL1,_BALL2,
  25.     SINGLE,BEST3,BEST5,UNLIMITED,STRIP,BALL10,BALL16,
  26.     OPPONENTBASE,ICON17,ICON18,ICON19,STRIPPERBASE };
  27.  
  28. extern struct NewScreen    ns;
  29. extern struct NewWindow    nw;
  30. extern struct Screen     *s,*s2;
  31. extern struct Window     *w,*w2;
  32. extern struct RastPort    *rp;
  33. extern struct ViewPort     *vp;
  34. extern struct ColorMap     *cm;
  35. extern struct FileHandle    *fh;
  36.  
  37. extern UWORD *colorpalette;
  38. extern UWORD rgb[32];
  39.  
  40. struct IFFGraphic
  41. {
  42. char        FileName[30];    /* Name of IFF file */
  43. BYTE        ReqDepth;        /* How many bitplanes wish to be Displayed */  
  44. USHORT    *RGB;        /* RGB colour values, filled by LoadIFF */ 
  45. short    Width;        /* Width of graphic, filled by LoadIFF */ 
  46. short    Height;        /* Height of graphic, filled by LoadIFF */ 
  47. BYTE        Depth;        /* Depth of graphic, filled by LoadIFF */ 
  48. };
  49.  
  50. extern struct IFFGraphic roomIFF;
  51. extern struct IFFGraphic offerIFF;
  52. struct IFFGraphic titleIFF =  { "FNPGRAPHICS:title.img",5,rgb };
  53. struct IFFGraphic settingsIFF =  { "FNPGRAPHICS:settings.img",5,rgb };
  54. struct IFFGraphic opponentIFF =  { "FNPGRAPHICS:opponent.img",5,rgb };
  55. struct IFFGraphic stripperIFF =  { "FNPGRAPHICS:stripper.img",5,rgb };
  56.  
  57. struct SnapShot { short x,y; };
  58. struct SnapShot snapshot[8] =
  59. { 6,44, 237,139, 6,146, 50,146, 93,146, 302,180, 0,0, 0,0 };
  60.  
  61.  
  62. struct iconstruct
  63. { short x1,y1,x2,y2,type; };
  64.  
  65. #define FLASH 1
  66. #define TICK 2
  67. #define CROSS 3
  68.  
  69. struct iconstruct icon[24] =
  70. {{ 5,43,59,97,FLASH },{ 71,43,125,97,FLASH },
  71. { 136,43,190,97,FLASH },{ 201,43,255,97,FLASH },
  72.  
  73. { 266,43,315,68,NULL },{ 266,73,315,98,NULL },
  74.  
  75. { 5,145,37,176,NULL },{ 49,145,81,176,NULL },{ 92,145,123,176,NULL },
  76.  
  77. { 236,138,248,150,TICK },{ 236,150,248,162,TICK },{ 236,162,248,174,TICK },
  78. { 236,174,248,186,TICK },{ 301,123,313,135,TICK }, { 301,167,313,179,TICK },
  79. { 301,179,313,191,TICK },
  80.     
  81. { 1,152,60,202,NULL },{ 1,206,60,256,NULL },
  82. { 1,44,60,94,NULL },{ 1,98,60,148,NULL },
  83.  
  84. { 161,174,220,223,NULL },{ 228,174,287,223,NULL },
  85. { 27,174,85,223,NULL },{ 94,174,153,223,NULL }};
  86.  
  87. UWORD chip tickmask[8] =
  88. { 0x0100,0x0300,0x0700,0x8e00,0xdc00,0xf800,0x7000,0x2000 };
  89.  
  90. UWORD chip xmask[7] =
  91. { 0xc600,0x6c00,0x3800,0x3800,0x6c00,0xc600,0x8200 };
  92.  
  93. UWORD chip pointeron[24] = {
  94. 0,0,0xc000,0x4000,0x7000,0xb000,0x3c00,0x4c00,0x3f00,0x4300,
  95. 0x1fc0,0x20c0,0x1fc0,0x2000,0x0f00,0x1100,0x0d80,0x1280,
  96. 0x04c0,0x0940,0x0460,0x08a0,0x0020,0x0040 };
  97.  
  98. UWORD chip pointeroff[8];
  99.  
  100. enum args { GAMETYPE,GAMELENGTH,BAIZE,BALL1,BALL2,BALLCOUNT,OPPONENT,STRIPPER };
  101.  
  102. #define NOPRESETS -1
  103.  
  104. char arg[8] = { PLYR1,SINGLE,0,0,2,16,0,0 },bufarg[8],demoarg[8];
  105. extern short defaultdemo,enableoptions;
  106.  
  107. UWORD flash;
  108.  
  109. struct shade { UWORD light,medium,dark; };
  110.  
  111. struct shade baizeRGB[] = {
  112. { 0x280,0x160,0x040 }, /* green */
  113. { 0x269,0x146,0x034 }, /* blue */
  114. { 0x954,0x743,0x521 }, /* brown */
  115. { 0x777,0x555,0x333 }}; /* grey */
  116.  
  117. struct shade ballRGB[] = {
  118. { 0xf00,0xc00,0x800 }, /* red */
  119. { 0xf60,0xe40,0xb20 }, /* orange */
  120. { 0xfc0,0xf90,0xb50 }, /* yellow */
  121. { 0x9d0,0x6b0,0x370 }, /* green */
  122. { 0x09f,0x07e,0x04a }, /* blue */
  123. { 0x90a,0x807,0x604 }, /* purple */
  124. { 0xf77,0xe55,0xa32 }}; /* pink */
  125.  
  126. /******* Audio stuff *************/
  127.  
  128. #define SAMPLES 8
  129.  
  130. enum sound { COLLIDE,STRIKE,BOUNCE,POTTED,CHEER,LONGCHEER,CHANT,CRASH };
  131.  
  132. struct audioinfostruct
  133. {
  134.     struct IOAudio *audio;
  135.     char *wave,bufstate,channel,flag;
  136.     long wavelen;
  137.     short volume,period;
  138.     char filename[30];
  139. };
  140. extern struct audioinfostruct audioinfo[SAMPLES];
  141.  
  142. char Loader(short);
  143. void FadeScreen(struct Screen *,short);
  144. char LoadIFF(struct IFFGraphic *,struct Screen *,char);
  145. void DoStripper(void);
  146. void DoOpponent(void);
  147. char DoSettings(short);
  148. void DrawSymbol(short,short);
  149. char ClickDelay(short);
  150. extern short GetMouse(void);
  151. extern short GetInput(void);
  152. extern void PlaySound(struct audioinfostruct *,short);
  153. extern UWORD Rand(UWORD);
  154. extern long MyRead(struct FileHandle *,long *,long);
  155.  
  156. #define RETURN 68
  157. #define LMOUSE 1
  158. #define RMOUSE 2
  159.  
  160. /************************/
  161. char Loader(start)
  162. short start;
  163. {
  164.     short i;
  165.     
  166.     if (start)
  167.     {
  168.         SetPointer(w,pointeroff,1,1,0,0);
  169.         SetPointer(w2,pointeroff,1,1,0,0);
  170. /*        LoadIFF(&offerIFF,s,VIEW); ClickDelay(1000); */
  171.         LoadIFF(&roomIFF,s2,VIEW); LoadIFF(&titleIFF,s,VIEW);
  172.         PlaySound(&audioinfo[STRIKE],64); Delay(10);
  173.         PlaySound(&audioinfo[COLLIDE],64); Delay(20);
  174.         PlaySound(&audioinfo[POTTED],64);
  175.         PlaySound(&audioinfo[LONGCHEER],64);
  176.         for (i=0; i<5; i++)
  177.         {
  178.             colorpalette[25] = 0xf7b; colorpalette[26] = 0xf2b;
  179.             colorpalette[27] = 0xfcc; MakeScreen(s); RethinkDisplay();
  180.             if (ClickDelay(50)) break;
  181.             colorpalette[25] = 0x77f; colorpalette[26] = 0x06d;
  182.             colorpalette[27] = 0xccf; MakeScreen(s); RethinkDisplay();
  183.             if (ClickDelay(50)) break;
  184.         }
  185.     }
  186.     LoadIFF(&settingsIFF,s,VIEW);
  187.     ActivateWindow(w);
  188.     if (enableoptions) SetPointer(w,pointeron,11,11,0,0);
  189.     else
  190.     {
  191.         SetPointer(w,pointeroff,1,1,0,0);
  192.         snapshot[GAMETYPE].x = 202;
  193.         snapshot[GAMELENGTH].x = 237;
  194.         snapshot[GAMELENGTH].y = 139;
  195.     }
  196.     for (i=GAMETYPE; i<OPPONENT; i++) DoSettings(i);
  197.  
  198.     if (!(DoSettings(NOPRESETS))) return(0);
  199.  
  200.     if (arg[GAMELENGTH]==STRIP)
  201.     {
  202.         LoadIFF(&stripperIFF,s,VIEW);
  203.         DoStripper();
  204.     }
  205.     else if (arg[GAMETYPE]==PLYR1)
  206.     {
  207.         LoadIFF(&opponentIFF,s,VIEW);
  208.         DoOpponent();
  209.     }
  210.     SetPointer(w,pointeroff,1,1,0,0);
  211.     return(1);
  212. }
  213. /************************/
  214. void DoStripper()
  215. {
  216.     while(1)
  217.     {
  218.         short x,y,i;
  219.         
  220.         x = s->MouseX; y = s->MouseY;
  221.         if (GetMouse() == LMOUSE)
  222.         {
  223.             for (i=STRIPPERBASE; i<(STRIPPERBASE+4); i++)
  224.             {
  225.                 if (x > icon[i].x1 && x < icon[i].x2 &&
  226.                     y > icon[i].y1 && y < icon[i].y2)
  227.                 {
  228.                     PlaySound(&audioinfo[COLLIDE],64);
  229.                     arg[STRIPPER] = i-STRIPPERBASE;
  230.                     arg[OPPONENT] = 0;
  231.                     return;
  232.                 }
  233.             }
  234.         }
  235.     }
  236. }
  237. /************************/
  238. void DoOpponent()
  239. {
  240.     while(1)
  241.     {
  242.         short x,y,i;
  243.         
  244.         x = s->MouseX; y = s->MouseY;
  245.         if (GetMouse() == LMOUSE)
  246.         {
  247.             for (i=OPPONENTBASE; i<(OPPONENTBASE+4); i++)
  248.             {
  249.                 if (x > icon[i].x1 && x < icon[i].x2 &&
  250.                     y > icon[i].y1 && y < icon[i].y2)
  251.                 {
  252.                     PlaySound(&audioinfo[COLLIDE],64);
  253.                     arg[OPPONENT] = i-OPPONENTBASE; return;
  254.                 }
  255.             }
  256.         }
  257.     }
  258. }
  259. /************************/
  260. void DrawBox(i,status)
  261. short i,status;
  262. {
  263.     if (status==ON) SetAPen(rp,31);
  264.     else SetAPen(rp,1);
  265.     
  266.     Move(rp,icon[i].x1,icon[i].y1); Draw(rp,icon[i].x2,icon[i].y1);
  267.     Draw(rp,icon[i].x2,icon[i].y2); Draw(rp,icon[i].x1,icon[i].y2);
  268.     Draw(rp,icon[i].x1,icon[i].y1);
  269. }
  270. /************************/
  271. void DrawSymbol(i,status)
  272. short i,status;
  273. {
  274.     SetAPen(rp,0);
  275.     RectFill(rp,icon[i].x1+3,icon[i].y1+3,icon[i].x1+10,icon[i].y1+10);
  276.     SetAPen(rp,3);
  277.     if (status==TICK)
  278.         BltPattern(rp,tickmask,icon[i].x1+3,icon[i].y1+3,icon[i].x1+10,icon[i].y1+10,2);
  279.     else if (status==CROSS) BltPattern(rp,xmask,icon[i].x1+3,icon[i].y1+3,icon[i].x1+10,icon[i].y1+9,2);
  280. }
  281. /************************/
  282. char DoSettings(preset)
  283. short preset;
  284. {
  285.     short count = (enableoptions)? 0:1250;
  286.     
  287.     while(1)
  288.     {
  289.         short x,y,i,j;
  290.         
  291.         flash+=0x111;
  292.         if (flash > 0xfff) flash=0;
  293.         colorpalette[31] = flash;
  294.         MakeScreen(s); RethinkDisplay();
  295.         for (i=0; i<32; i++) colorpalette[i] = rgb[i];
  296.         
  297.         if (preset==NOPRESETS) { x = s->MouseX; y = s->MouseY; }
  298.         else { x = snapshot[preset].x; y = snapshot[preset].y; }
  299.         if (GetMouse() == LMOUSE || ++count==1500 || preset!=NOPRESETS)
  300.         {
  301.             if (count==1500)
  302.             {
  303.                 for (i=0; i<8; i++) bufarg[i] = arg[i];
  304.                 demoarg[GAMETYPE] = DEMO;
  305.                 demoarg[GAMELENGTH] = SINGLE;
  306.                 if (demoarg[BALLCOUNT] == 16) demoarg[BALLCOUNT] = 10;
  307.                 else demoarg[BALLCOUNT] = 16;
  308.                 demoarg[BALL1] = Rand(7);
  309.                 do { demoarg[BALL2] = Rand(7); }
  310.                 while (demoarg[BALL2]==demoarg[BALL1]);
  311.                 if (++demoarg[BAIZE] > 3) demoarg[BAIZE] = 0;    
  312.                 for (i=0; i<8; i++) arg[i] = demoarg[i];
  313.                 defaultdemo=TRUE; return(TRUE);
  314.             }
  315.             while(GetMouse() == LMOUSE && enableoptions);
  316.             
  317.             if (enableoptions || preset!=NOPRESETS)
  318.             for (count=0,i=0; i<OPPONENTBASE; i++)
  319.             {
  320.                 if (x > icon[i].x1 && x < icon[i].x2 &&
  321.                     y > icon[i].y1 && y < icon[i].y2)
  322.                 {
  323.                     if (preset==NOPRESETS) PlaySound(&audioinfo[COLLIDE],64);
  324.                     if (icon[i].type==FLASH)
  325.                     {
  326.                         snapshot[GAMETYPE].x = x;
  327.                         snapshot[GAMETYPE].y = y;
  328.                     
  329.                         for (j=0; j<4; j++) DrawBox(j,OFF);
  330.                         DrawBox(i,ON); arg[GAMETYPE] = i;
  331.                     
  332.                         switch(i)
  333.                         {
  334.                             case PLYR1:
  335.                             case PLYR2:
  336.                                 for (j=9; j<14; j++) DrawSymbol(j,OFF);
  337.                                 if (i==PLYR2) DrawSymbol(STRIP,CROSS);
  338.                                 DrawSymbol(SINGLE,TICK);
  339.                                 arg[GAMELENGTH] = SINGLE;
  340.                                 snapshot[GAMELENGTH].x = 237;
  341.                                 snapshot[GAMELENGTH].y = 139;
  342.                                 break;
  343.                             case PRACTICE:
  344.                                 for (j=9; j<14; j++) DrawSymbol(j,CROSS);
  345.                                 DrawSymbol(UNLIMITED,TICK);
  346.                                 arg[GAMELENGTH] = UNLIMITED;
  347.                                 snapshot[GAMELENGTH].x = 237;
  348.                                 snapshot[GAMELENGTH].y = 175;
  349.                                 break;
  350.                             case DEMO:
  351.                                 for (j=9; j<14; j++) DrawSymbol(j,OFF);
  352.                                 DrawSymbol(STRIP,CROSS);
  353.                                 DrawSymbol(UNLIMITED,TICK);
  354.                                 arg[GAMELENGTH] = UNLIMITED;
  355.                                 snapshot[GAMELENGTH].x = 237;
  356.                                 snapshot[GAMELENGTH].y = 175;
  357.                                 break;
  358.                         }
  359.                     }
  360.                     else if (icon[i].type==TICK)
  361.                     {
  362.                         if (i==BALL10 || i==BALL16)
  363.                         {
  364.                             snapshot[BALLCOUNT].x = x;
  365.                             snapshot[BALLCOUNT].y = y;
  366.  
  367.                             DrawSymbol(BALL10,OFF);
  368.                             DrawSymbol(BALL16,OFF);
  369.                             DrawSymbol(i,TICK);
  370.                             arg[BALLCOUNT] = (i==BALL10)? 10:16;
  371.                         }
  372.                         else if (!(arg[GAMETYPE]!=PLYR1 && i==STRIP)
  373.                             && arg[GAMETYPE]!=PRACTICE)
  374.                         {
  375.                             snapshot[GAMELENGTH].x = x;
  376.                             snapshot[GAMELENGTH].y = y;
  377.                             
  378.                             DrawSymbol(arg[GAMELENGTH],OFF);
  379.                             DrawSymbol(i,TICK);
  380.                             arg[GAMELENGTH] = i;
  381.                         }
  382.                     }
  383.                     else switch(i)
  384.                     {
  385.                         case _BAIZE:
  386.                             snapshot[BAIZE].x = x;
  387.                             snapshot[BAIZE].y = y;
  388.                             if (preset==NOPRESETS && ++arg[BAIZE] > 3) arg[BAIZE] = 0;
  389.                             rgb[24] = baizeRGB[arg[BAIZE]].light;
  390.                             rgb[7] = baizeRGB[arg[BAIZE]].medium;
  391.                             rgb[6] = baizeRGB[arg[BAIZE]].dark;
  392.                             break;
  393.                         
  394.                         case _BALL1:
  395.                             snapshot[BALL1].x = x;
  396.                             snapshot[BALL1].y = y;
  397.                             if (preset==NOPRESETS)
  398.                                 do if (++arg[BALL1] > 6) arg[BALL1] = 0;
  399.                             while (arg[BALL1]==arg[BALL2]);
  400.                             rgb[9]=ballRGB[arg[BALL1]].light;
  401.                             rgb[8]=ballRGB[arg[BALL1]].medium;
  402.                             rgb[22]=ballRGB[arg[BALL1]].dark;
  403.                             break;
  404.                             
  405.                         case _BALL2:
  406.                             snapshot[BALL2].x = x;
  407.                             snapshot[BALL2].y = y;
  408.                             if (preset==NOPRESETS)
  409.                                 do if (++arg[BALL2] > 6) arg[BALL2] = 0;
  410.                             while (arg[BALL1]==arg[BALL2]);
  411.                             rgb[12]=ballRGB[arg[BALL2]].light;
  412.                             rgb[11]=ballRGB[arg[BALL2]].medium;
  413.                             rgb[23]=ballRGB[arg[BALL2]].dark;
  414.                             break;
  415.                         
  416.                         case PLAY: return(TRUE);
  417.                         case QUIT: return(FALSE);
  418.                     }
  419.                 }
  420.             }
  421.         }
  422.         if (preset!=NOPRESETS) return(TRUE);
  423.     }
  424. }
  425. /****************************/
  426. char LoadIFF(img,screen,opt)
  427. struct IFFGraphic *img;
  428. struct Screen *screen;
  429. char opt;
  430. {
  431.     char    err = 0,ChosenDepth;
  432.     unsigned char *buffer;
  433.     short i,j,column[5],store,store2,remain = 0;
  434.     UWORD *colorpalette;
  435.     long length,pos[5],fpos = 0;
  436.     struct BitMap *BMap = &screen->BitMap;
  437.     struct FileHandle *fh;
  438.     /* `buffer' must be long aligned */
  439.     if (!(buffer = (char *)AllocMem(4096,MEMF_PUBLIC))) return(5);    
  440.     while(!(fh = (struct FileHandle *)Open(img->FileName,MODE_OLDFILE)));
  441.     {
  442.         MyRead(fh,buffer,30);
  443.         if (strncmp(buffer,"FORM",4))         { err = 2; goto Escape; }
  444.         if (strncmp(&buffer[8],"ILBMBMHD",8))    { err = 3; goto Escape; }
  445.  
  446.         /** File is an IFF graphic! **/
  447.         
  448.         img->Width  = *((short *)&buffer[20]);
  449.         img->Height = *((short *)&buffer[22]);
  450.         img->Depth  = buffer[28];
  451.         
  452.         /* Don't load more bitplanes on a screen than it can handle! */
  453.         if (!img->ReqDepth || img->ReqDepth > BMap->Depth)
  454.             img->ReqDepth = BMap->Depth;
  455.         
  456.         /* Locate the start of CMAP */
  457.         
  458.         Seek(fh,20+ *((long *)&buffer[16]),OFFSET_BEGINNING);
  459.         MyRead(fh,buffer,8);
  460.         if (strncmp(buffer,"CMAP",4)) { err = 4; goto Escape; }
  461.  
  462.         if (opt==VIEW) FadeScreen(screen,DOWN);
  463.         
  464.         /* Now read the RGB values */
  465.         for (i=0; i < (1 << img->Depth); i++)
  466.         {
  467.             MyRead(fh,buffer,3);
  468.             if (img->RGB) img->RGB[i] = (USHORT)
  469.             ((((long)buffer[0])<<4) | ((long)buffer[1]) | buffer[2]>>4);
  470.         }
  471.         if (!opt) goto Escape;    /* Program requested NOT to load pic */
  472.  
  473.         MyRead(fh,buffer,8);        /* DPPV? */
  474.         /* Don't know what following data is for - skip to image data */
  475.         for (i=0; i<10; i++)
  476.         {
  477.             Seek(fh,*((long *)&buffer[4]),OFFSET_CURRENT);
  478.             MyRead(fh,buffer,8);
  479.             if (!strncmp(buffer,"BODY",4)) goto FoundPicData;
  480.         }
  481.         err = 4; goto Escape;
  482.  
  483. FoundPicData:
  484.  
  485.         length = BMap->BytesPerRow * BMap->Rows;
  486.         colorpalette = (UWORD *)screen->ViewPort.ColorMap->ColorTable;
  487.         if (img->Depth < img->ReqDepth) ChosenDepth = img->Depth;
  488.         else ChosenDepth = img->ReqDepth;
  489.         pos[0]=pos[1]=pos[2]=pos[3]=pos[4]=0;
  490.         column[0]=column[1]=column[2]=column[3]=column[4]=0;
  491.         if (opt == 1)
  492.         {
  493.             for (i=0; i< 1 << ChosenDepth; i++)
  494.                 *(colorpalette+i) = img->RGB[i];
  495.         }
  496.         /***** Reading graphic image *****/
  497.         while(1)
  498.         {
  499.             for (i=0; i<img->Depth; i++)
  500.             {
  501. LineNotComplete:    if (!remain) { remain = MyRead(fh,buffer,4096); fpos=0; }
  502.                 if (!remain) goto Escape2;         /* End Of File */
  503.                 if (pos[i] >= length) goto Escape2; /* Filled screen */
  504.                 
  505.     /* NB: `pos' is only incremented for depths which will be     */
  506.     /* displayed. It is pointless and more lengthy to increment   */
  507.     /* any elements of `pos' that will not be used in the display */
  508.                 
  509.                 if (buffer[fpos] < 128)
  510.                 {
  511.                     for (j=0,store = buffer[fpos++]; j<=store; j++,column[i]++,fpos++)
  512.                     {
  513.                         if (!(--remain))
  514.                         { remain = MyRead(fh,buffer,4096); fpos=0; }    
  515.                         if (i < img->ReqDepth && column[i] < BMap->BytesPerRow)
  516.                           *(BMap->Planes[i] + pos[i]++) = buffer[fpos];
  517.                     }
  518.                 }
  519.                 else
  520.                 {
  521.                     store = 256-buffer[fpos++];
  522.                     if (!(--remain))
  523.                     { remain = MyRead(fh,buffer,4096); fpos=0; }
  524.                     for (j=0,store2 = buffer[fpos++]; j<=store; j++,column[i]++)
  525.                     {
  526.                         if (i < img->ReqDepth && column[i] < BMap->BytesPerRow)
  527.                           *(BMap->Planes[i] + pos[i]++) = store2;
  528.                     }
  529.                 }
  530.                 --remain;        
  531.                 if (column[i] < img->Width>>3) goto LineNotComplete;
  532.                 column[i] = 0;
  533.             }
  534.         }
  535. Escape2:
  536.         /* Clear any portions of screen not loaded into */
  537.         for (fpos=pos[i]; fpos<length; fpos++)
  538.             for (i=0; i<img->ReqDepth; i++)
  539.                 *(BMap->Planes[i] + fpos) = 0;
  540.  
  541.         /* Clear the whole screen of surplus bitplanes */
  542.         for (fpos=0; fpos<length; fpos++)
  543.             for (i=img->Depth; i<img->ReqDepth; i++)
  544.                 *(BMap->Planes[i] + fpos) = 0;
  545. Escape:
  546.         Close(fh);
  547.         if (opt==VIEW) FadeScreen(screen,UP);
  548.     }
  549.     /* else err = 1; */
  550.     FreeMem(buffer,4096);
  551.     return(err);
  552. }
  553. /**************************/
  554. char ClickDelay(time)
  555. short time;
  556. {
  557.     while (GetInput() != RETURN && !GetMouse() && --time) Delay(1);
  558.     if (time) return(1);
  559.     return(0);
  560. }
  561. /**************************/
  562. void FadeScreen(scrn,flag)
  563. struct Screen *scrn;
  564. short flag;
  565. {
  566.     short j,red,grn,blu,i,val;
  567.     USHORT col,*cp = s->ViewPort.ColorMap->ColorTable;
  568.     
  569.     for (i=0; i<=16; i++)
  570.     {
  571.         for (j=0; j<32; j++)
  572.         {
  573.             val = (flag==DOWN)? 16-i:i;
  574.             col = rgb[j];
  575.             red = (((col >> 8) & 0xf) * val) >> 4;
  576.             grn = (((col >> 4) & 0xf) * val) >> 4;
  577.             blu =  ((col         & 0xf) * val) >> 4;
  578.             cp[j] = (red<<8) | (grn<<4) | blu;
  579.         }
  580.         MakeScreen(scrn); RethinkDisplay();
  581.     }
  582. }
  583.